
<template>
  <div class="table-page">
    <div class="query">
      <el-form label-position="left" :inline='true'>
        <el-row>
          <el-col>
            <el-button type="success" v-on:click="add" style="margin-top:20px;margin-left:20px">新增</el-button>
          </el-col>
        </el-row>
      </el-form>
    </div>
    <div class="app-container">
      <el-table :data="this.list" border  v-loading="loading">
        <el-table-column type="index" label="行号" width="50" header-align="center" align="center"></el-table-column>
        <el-table-column prop="name" label="客户名称"></el-table-column>      
        <el-table-column  prop="email" label="邮箱"></el-table-column>
        <el-table-column  prop="FBaddress" label="FB地址"></el-table-column>
        <el-table-column prop="product" label="测评产品"></el-table-column>
        <el-table-column  prop="historyOrderNo" label="历史订单号"></el-table-column>
        <el-table-column  prop="reviewLinker" label="回评链接"></el-table-column>
        <el-table-column  width="100" fixed="right" label="操作" align="center">
          <template slot-scope="scope">
            <el-button type="primary" size="small" @click.native.prevent="edit(scope.row)">编辑</el-button>
          </template>
        </el-table-column>
      </el-table>
    </div>

    <el-dialog title="新增客户信息" :visible.sync="openEditWindow" :close-on-click-modal="false">
      <partnerEdit ref="partnerEdit" @refresh="refresh"></partnerEdit>
    </el-dialog>
  </div>
</template>

<script>
import partnerEdit from "./edit";
import {getList} from "@/api/partner"

export default {
    name: "index",
  data() {
    return {
      keyword: "",
      loading: false,
      openEditWindow: false,
      tableHeight: window.innerHeight - 260,
      list: null
    };
  },
  components: {
    partnerEdit
  },
  created() {
    this.query();
  },
  methods: {
    query() {
      getList().then(Response=>{
        this.list=Response.data
        this.loading=false
      })
    },
    add() {
      this.openEditWindow = true;
      //需要子组件渲染DOM后才能执行
      this.$nextTick(() => {
        this.$refs.partnerEdit.initData();
      });
    },
    edit(m) {
      this.openEditWindow = true;
      //需要子组件渲染DOM后才能执行
      this.$nextTick(() => {
        this.$refs.partnerEdit.initData(m);
      });
    },
    refresh() {
      this.openEditWindow = false;
      this.query();
    }
  }
};
</script>

